/*********************************************************************************
File Sample.cpp		author belot nicolas (karrakis)
define Class Sample
an interface for managing samples


**********************************************************************************/


#include "Sample.h"
#include <stdio.h>
#include <iostream>
#include <cassert>
namespace libtrckr {
/*bool Sample::BufferAllocate(int size=MIN_BUFF_SIZE){
	if(size % MIN_BUFF_SIZE != 0){
		//size = ((size / MIN_BUFF_SIZE) + 1) * MIN_BUFF_SIZE;
		//size = size / MIN_BUFF_SIZE * MIN_BUFF_SIZE + MIN_BUFF_SIZE; 
		size+= MIN_BUFF_SIZE - size % MIN_BUFF_SIZE; 
	}
	_buffer = malloc(size);
	return (_buffer!=0);
}

void Sample::BufferDesallocate(){
	return free(_buffer);
}*/
Sample::Sample():_bitrate(0){ 
	
}

Sample::~Sample(){

}

Sample::Sample(Sample &s):_bitrate(s.getBitrate()){

}

void Sample::setBitrate(int bitrate){
	_bitrate=bitrate;
}

int Sample::getBitrate( ) const {
	return _bitrate;
}

Buffer& operator<<(Buffer& b,Sample& s){
	//b.flush();
	if(b.full()){
		 std::cerr << "trying to fill full buffer..." << std::endl;
	}
	while(!b.full() && !s.isEOF()){
		s.read(b);
	}
	return b;
}

Buffer& operator>>(Buffer& b,Sample& s){
	//b.flush();
	while(!b.full() && !s.isEOF()){
		s.read(b);
	}
	return b;
}
}

